﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Forums
{
    using System;
    using System.Collections.Generic;
    using System.Security.Cryptography;

    /// <summary>Represents a forum host.</summary>
    /// <threadsafety static="true" instance="false"/>
    public interface IHost : IDeletablePersistentObject
    {
        /// <summary>Gets the network name of the host.</summary>
        string Name { get; }

        /// <summary>Gets the port of the host.</summary>
        int Port { get; }

        /// <summary>Gets or sets the posting user name for the host.</summary>
        /// <exception cref="InvalidOperationException">Set a value after <see cref="Cache.Dispose"/> has been called
        /// on the parent <see cref="Cache"/> object, or, set a value after
        /// <see cref="IDeletablePersistentObject.Delete"/> has been called on this object.</exception>
        string UserName { get; set; }

        /// <summary>Gets or sets the posting email address for the host.</summary>
        /// <exception cref="InvalidOperationException">Set a value after <see cref="Cache.Dispose"/> has been called
        /// on the parent <see cref="Cache"/> object, or, set a value after
        /// <see cref="IDeletablePersistentObject.Delete"/> has been called on this object.</exception>
        string EmailAddress { get; set; }

        /// <summary>Gets or sets the logon account name for the host.</summary>
        /// <exception cref="CryptographicException">The account name could not be decrypted. This usually happens when
        /// a different user attempts to get the account name than the one who has set it.</exception>
        /// <exception cref="InvalidOperationException"><see cref="Cache.Dispose"/> has been called on the parent
        /// <see cref="Cache"/> object, or, <see cref="IDeletablePersistentObject.Delete"/> has been called on this
        /// object.</exception>
        string AccountName { get; set; }

        /// <summary>Gets or sets the logon password for the host.</summary>
        /// <exception cref="CryptographicException">The password could not be decrypted. This usually happens when
        /// a different user attempts to get the password than the one who has set it.</exception>
        /// <exception cref="InvalidOperationException"><see cref="Cache.Dispose"/> has been called on the parent
        /// <see cref="Cache"/> object, or, <see cref="IDeletablePersistentObject.Delete"/> has been called on this
        /// object.</exception>
        string Password { get; set; }

        /// <summary>Adds a new group to the cache and returns an object representing the group.</summary>
        /// <param name="groupName">The name of the forum group.</param>
        /// <param name="groupDisplayName">The display name of the group.</param>
        /// <param name="newInboundArticlesReceiveLimit">The maximum number of new articles for which information is
        /// received during each send/receive operation started with <see cref="Cache.SendReceiveAsync"/>.</param>
        /// <param name="cachedInboundArticlesLimit">The maximum number of articles that are held in the cache.</param>
        /// <exception cref="ArgumentOutOfRangeException"><list type="bullet">
        /// <item><paramref name="newInboundArticlesReceiveLimit"/> is 0 or negative; or</item>
        /// <item><paramref name="cachedInboundArticlesLimit"/> is 0 or negative.</item>
        /// </list></exception>
        /// <exception cref="InvalidOperationException"><see cref="Cache.Dispose"/> has been called on the parent
        /// <see cref="Cache"/> object, or, <see cref="IDeletablePersistentObject.Delete"/> has been called on this
        /// object.</exception>
        IGroup AddGroup(
            string groupName,
            string groupDisplayName,
            int newInboundArticlesReceiveLimit,
            int cachedInboundArticlesLimit);

        /// <summary>Gets the groups that have been added to this host with <see cref="AddGroup"/>.</summary>
        /// <exception cref="InvalidOperationException"><see cref="Cache.Dispose"/> has been called on the parent
        /// <see cref="Cache"/> object, or, <see cref="IDeletablePersistentObject.Delete"/> has been called on this
        /// object.</exception>
        IEnumerable<IGroup> Groups { get; }

        /// <summary>Adds a new outbound article to the cache and returns an object representing the article.</summary>
        /// <exception cref="InvalidOperationException"><see cref="Cache.Dispose"/> has been called on the parent
        /// <see cref="Cache"/> object, or, <see cref="IDeletablePersistentObject.Delete"/> has been called on this
        /// object.</exception>
        IOutboundArticle AddOutboundArticle();
    }
}
